# import matplotlib.pyplot as plt
# import numpy as np
# from pylab import mpl
# plt.rcParams['font.sans-serif'] = ['SimHei']
# plt.figure(figsize=(30,15), dpi=100)
#
# plt.subplot(2,1,1)
# y_greedy = [
# 2185,
# 2102,
# 2256,
# 2204,
# 2187,
# 2067,
# 2167,
# 2287,
# 2207
# ]
# y_SMF = [
# 2366,
# 2445,
# 2589,
# 2531,
# 2440,
# 2496,
# 2486,
# 2497,
# 2594
#
# ]
# y_KM =[
# 2366,
# 2445,
# 2589,
# 2531,
# 2440,
# 2496,
# 2486,
# 2497,
# 2594
# ]
# y_NRKM=[
# 2366,
# 2445,
# 2589,
# 2531,
# 2440,
# 2496,
# 2486,
# 2497,
# 2594
#
# ]
# y_TGOA=[
# 2245,
# 2278,
# 2315,
# 2347,
# 2207,
# 2173,
# 2238,
# 2317,
# 2343
# ]
# labels = [ '数据集1', '数据集2','数据集3','数据集4','数据集5','数据集6','数据集7','数据集8','数据集9']
# bar_width = 0.15
#
# # 绘图
#
# plt.bar(np.arange(9), y_greedy, label='GA', color='WHITE', alpha=1, width=bar_width,edgecolor="k",hatch='/')
# plt.bar(np.arange(9) + bar_width, y_SMF, label='SMF', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="***")
# plt.bar(np.arange(9) + 2*bar_width, y_KM, label='KM', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="xxx")
# plt.bar(np.arange(9) + 3*bar_width, y_NRKM, label='NR-KM', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="-")
# plt.bar(np.arange(9) + 4*bar_width, y_TGOA, label='TGOA', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch=".")
# # 添加刻度标签
# plt.xticks(np.arange(9) + bar_width, labels)
# plt.tick_params(labelsize=40)
# # 设置Y轴的刻度范围
#
# plt.ylim([1200,3000])
# # plt.xlabel('(a)时间片的影响',fontsize=40) #X轴标签
# plt.ylabel("任务分配数量",fontsize=40) #Y轴标签
# # 显示图例
# plt.legend(fontsize=30)
#
# plt.subplot(2,1,2)
# y_greedy = [
# 1645,
# 1676,
# 1687,
# 1672,
# 1682,
# 1585,
# 1615,
# 1772,
# 1754
#
# ]
# y_SMF = [
# 1989,
# 1998,
# 2017,
# 2007,
# 2010,
# 1945,
# 1985,
# 2110,
# 2126
#
# ]
# y_KM =[
# 1989,
# 1998,
# 2017,
# 2007,
# 2010,
# 1945,
# 1985,
# 2110,
# 2126
# ]
# y_NRKM=[
# 1989,
# 1998,
# 2017,
# 2007,
# 2010,
# 1945,
# 1985,
# 2110,
# 2126
# ]
# y_TGOA=[
# 1716,
# 1776,
# 1761,
# 1804,
# 1702,
# 1678,
# 1725,
# 1828,
# 1812
#
#
# ]
# labels =[ '数据集1', '数据集2','数据集3','数据集4','数据集5','数据集6','数据集7','数据集8','数据集9']
# bar_width = 0.15
#
# # 绘图
#
# plt.bar(np.arange(9), y_greedy, label='GA', color='WHITE', alpha=1, width=bar_width,edgecolor="k",hatch='/')
# plt.bar(np.arange(9) + bar_width, y_SMF, label='SMF', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="***")
# plt.bar(np.arange(9) + 2*bar_width, y_KM, label='KM', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="xxx")
# plt.bar(np.arange(9) + 3*bar_width, y_NRKM, label='NR-KM', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="-")
# plt.bar(np.arange(9) + 4*bar_width, y_TGOA, label='TGOA', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch=".")
# # 添加刻度标签
# plt.xticks(np.arange(9) + bar_width, labels)
# plt.tick_params(labelsize=40)
# # 设置Y轴的刻度范围
#
# plt.ylim([1200,2600])
# # plt.xlabel('（b）工人可达范围的影响',fontsize=40) #X轴标签
# plt.ylabel("任务分配兴趣度",fontsize=40) #Y轴标签
# # 显示图例
# plt.legend(fontsize=30)
#
# # plt.subplot(1,1,1)
# # y_greedy = [5.76,
# # 6.48,
# # 6.48,
# # 6.912
# # ]
# # y_SMF = [4.032,
# # 4.212,
# # 4.608,
# # 4.608
# # ]
# # y_KM =[3.024,
# # 3.456,
# # 3.888,
# # 4.032
# #
# # ]
# # # y_NRKM=[1862,
# # # 1910,
# # # 2117,
# # # 2049
# # # ]
# # labels = ['5', '10', '15','20']
# # bar_width = 0.2
# #
# # # 绘图
# #
# # plt.bar(np.arange(4), y_greedy, label='GA', color='WHITE', alpha=1, width=bar_width,edgecolor="k",hatch='/')
# # plt.bar(np.arange(4) + bar_width, y_SMF, label='GPA', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="-")
# # plt.bar(np.arange(4) + 2*bar_width, y_KM, label='PRA', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="xxx")
# # # plt.bar(np.arange(4) + 3*bar_width, y_NRKM, label='NR-KM', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="***")
# # # 添加刻度标签
# # plt.xticks(np.arange(4) + bar_width, labels)
# # plt.tick_params(labelsize=40)
# # # 设置Y轴的刻度范围
# #
# # plt.ylim([2500,3500])
# # plt.xlabel('时间片大小',fontsize=40) #X轴标签
# # plt.ylabel("团队多样性分数",fontsize=40) #Y轴标签
# # 显示图例
# plt.legend(fontsize=30)
# plt.tight_layout(pad=2, w_pad=5.0, h_pad=1.0)
# plt.savefig('C:\\Users\\lhh\\Desktop\\拒绝的数据\\新不同数据集上四种算法分配任务数量和兴趣度.png',dpi = 150)
# # 显示图形
# plt.show()

# ***************
# ***************
# ***************

# import matplotlib.pyplot as plt
# import numpy as np
# from pylab import mpl
# plt.rcParams['font.sans-serif'] = ['SimHei']
# plt.figure(figsize=(30,15), dpi=98)
#
# plt.subplot(1,2,1)
# y_greedy = [66.417,
# 62.613,
# 68.672,
# 71.769,
# ]
# y_SMF = [71.971,
# 74.022,
# 76.704,
# 83.704,
# ]
# y_KM = [71.971,
# 74.022,
# 76.704,
# 83.704,
# ]
# y_NRKM=[ 71.971,
# 74.022,
# 76.704,
# 83.704
# ]
# labels = ['120', '180', '240','300']
# bar_width = 0.2
#
# # 绘图
#
# plt.bar(np.arange(4), y_greedy, label='GA', color='WHITE', alpha=1, width=bar_width,edgecolor="k",hatch='/')
# plt.bar(np.arange(4) + bar_width, y_SMF, label='SMF', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="***")
# plt.bar(np.arange(4) + 2*bar_width, y_KM, label='KM', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="xxx")
# plt.bar(np.arange(4) + 3*bar_width, y_NRKM, label='NR-KM', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="-")
# # 添加刻度标签
# plt.xticks(np.arange(4) + bar_width, labels)
# plt.tick_params(labelsize=40)
# # 设置Y轴的刻度范围
#
# plt.ylim([60,90])
# plt.xlabel('（a）时间片的影响',fontsize=40) #X轴标签
# plt.ylabel("任务分配数量(10^3)",fontsize=40) #Y轴标签
# # 显示图例
# plt.legend(fontsize=30)
#
# plt.subplot(1,2,2)
# y_greedy = [56.151,57.892,68.672]
# y_SMF = [56.874,
# 63.092,
# 76.704
# ]
# y_KM = [56.874,
# 63.092,
# 76.704
# ]
# y_NRKM=[56.874,
# 63.092,
# 76.704
# ]
# labels = ['1', '2', '3']
# bar_width = 0.2
#
# # 绘图
#
# plt.bar(np.arange(3), y_greedy, label='GA', color='WHITE', alpha=1, width=bar_width,edgecolor="k",hatch='/')
# plt.bar(np.arange(3) + bar_width, y_SMF, label='SMF', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="***")
# plt.bar(np.arange(3) + 2*bar_width, y_KM, label='KM', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="xxx")
# plt.bar(np.arange(3) + 3*bar_width, y_NRKM, label='NR-KM', color='WHITE', alpha=1, edgecolor="k",width=bar_width,hatch="-")
# # 添加刻度标签
# plt.xticks(np.arange(3) + bar_width, labels)
# plt.tick_params(labelsize=40)
# # 设置Y轴的刻度范围
#
# plt.ylim([50,80])
# plt.xlabel('（b）工人可达范围的影响',fontsize=40) #X轴标签
# plt.ylabel("任务分配数量(10^3)",fontsize=40) #Y轴标签
# # 显示图例
# plt.legend(fontsize=30)
# # plt.tight_layout(pad=2, w_pad=5.0, h_pad=1.0)
# plt.savefig('D:\\Documents\\数量2.png',dpi = 100)
# # 显示图形
# plt.show()


# 这块是折线图
import  matplotlib.pyplot as plt
import numpy as np
from matplotlib import pyplot
plt.rcParams['font.sans-serif']=['SimHei'] # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False # 用来正常显示负号
plt.figure(figsize=(30,15), dpi=100)
plt.figure(1)
ax1 = plt.subplot(111)
x = ['1K', '2K','3K','3.5K']
y_greedy = [
5.76,
6.48,
6.48,
6.912
]
y_SMF = [4.032,
4.212,
4.608,
4.608

]
y_KM =[3.024,
3.456,
3.888,
4.032

]
y_NRKM=[6.912,
7.46,
8.064,
11.52

]
y_TGOA=[6.48,
6.48,
7.056,
8.064
]
plt.xticks(fontsize=40)
plt.yticks(fontsize=40)
plt.xlabel("时间片大小的影响",fontsize=40) #Y轴标签
plt.ylabel("CPU时间（s）",fontsize=40) #Y轴标签
pyplot.yticks([0,2,4,6,8,10])
plt.plot(x, y_greedy, marker='*', markersize=20, label='GA',color='black')
plt.plot(x, y_SMF, marker='s', markersize=20,label='GPA',color='black')
plt.plot(x, y_KM, marker='x', markersize=20,label='PRA',color='black')
plt.plot(x, y_NRKM, marker='^', markersize=20,label='g-D&C',color='black')
plt.plot(x, y_TGOA, marker='.', markersize=20,label='ADAPTIVE',color='black')
plt.legend(fontsize=30)  # 让图例生效

# ax2 = plt.subplot(122)
# x =  ['0', '2', '3','4','5']
# y_greedy = [0,
#          15.0187,
# 17.0187,
# 33.0374,
# 53.0374
# ]
# y_SMF=[0,12.0423,
# 13.0423,
# 23.0846,
# 50.0846
# ]
# y_KM  = [0,
# 12.6556,
# 13.6556,
# 25.3112,
# 45.3112
# ]
# y_NRKM=[0,
# 11.29,
# 12.289,
# 21.578,
# 40.578
#
# ]
# y_TGOA=[0,
# 12,
# 13,
# 24,
# 52
# ]
# plt.xticks(fontsize=40)
# plt.yticks(fontsize=40)
# plt.xlabel("(b)工人可达范围的影响",fontsize=40) #Y轴标签
# plt.ylabel("CPU时间成本(s)",fontsize=40) #Y轴标签
# pyplot.yticks([0,10,20,30,40,50])
# plt.ylabel("CPU时间成本(s)",fontsize=40) #Y轴标签
# plt.plot(x, y_greedy, marker='*', markersize=20, label='GA',color='black')
# plt.plot(x, y_SMF, marker='s', markersize=20,label='SMF',color='black')
# plt.plot(x, y_KM, marker='x', markersize=20,label='KM',color='black')
# plt.plot(x, y_NRKM, marker='^', markersize=20,label='NR-KM',color='black')
# plt.plot(x, y_TGOA, marker='.', markersize=20,label='TGOA',color='black')
# plt.legend(fontsize=30)  # 让图例生效
plt.tight_layout(pad=2, w_pad=5.0, h_pad=1.0)
plt.savefig('C:\\Users\\lhh\\Desktop\\团队分配数据\\data\\新的时间片大小时间影响.png', dpi=200, bbox_inches='tight')
plt.show()
